package comxxxx.service.impl;

import comxxxx.pojo.Order;
import comxxxx.service.OrderService;
import comxxxx.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import java.util.Arrays;

/**
 * @author zzuli_huahua
 * @version 1.0
 * @date 2022/2/12 11:09
 */
@Service
public class OrderServiceImpl implements OrderService
{
    @Qualifier("product-service")
    @Autowired
    private ProductService productService;

    /**
     * 根据主键查询订单
     * @param id
     * @return
     */
    @Override
    public Order selectOrderById(Integer id) {
        return new Order(id,"order-001","中国",227888D,
                productService.selectProductList());
    }

    /**
     * 根据主键查询订单
     * @param id
     * @return
     */
    @Override
    public Order queryOrderById(Integer id) {
        return new Order(id,"order-002","中国",11600D,
                productService.selectProductListByIds(Arrays.asList(1,2)));
    }

    /**
     * 根据主键查询订单
     * @param id
     * @return
     */
    @Override
    public Order searchOrderById(Integer id) {
        return new Order(id,"order-003","中国",26666D,
               Arrays.asList( productService.selectProductListById(5)));
    }
}
